﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoastalClimbing.Code;

namespace CoastalClimbing
{
    public partial class Floors : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                DataTable chartInfo = DAL.GetChartData();

                List<DictionaryEntry> data = new List<DictionaryEntry>();
                List<DictionaryEntry> big = new List<DictionaryEntry>();

                foreach (DataRow row in chartInfo.Rows)
                {
                    string rating = row["RATING"].ToString();

                    //if (rating.Replace("V", "").Count() == 1)
                    //{
                    //    data.Add(new DictionaryEntry(rating, row["NUMOF"].ToString()));
                    //}
                    //else
                    //{
                        big.Add(new DictionaryEntry(rating, row["NUMOF"].ToString()));
                    //}
                }

                data.AddRange(big);

                if (data != null && data.Count > 0)
                {
                    chtRoutes.Visible = true;
                    chtRoutes.ImageStorageMode = System.Web.UI.DataVisualization.Charting.ImageStorageMode.UseImageLocation;
                    chtRoutes.Series["Routes"].Points.DataBindXY(data, "KEY", data, "VALUE");
                    chtRoutes.ChartAreas[0].AxisX.Interval = 1;
                }
                else
                {
                    chtRoutes.Visible = false;
                }            
            }
        }
    }
}